package com.synergy.stockflow.sales.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.synergy.stockflow.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.synergy.stockflow.sales.mapper.CustomerResourcesMapper;
import com.synergy.stockflow.sales.entity.CustomerResources;
import com.synergy.stockflow.sales.service.CustomerResourcesService;
@Service
public class CustomerResourcesServiceImpl extends ServiceImpl<CustomerResourcesMapper, CustomerResources> implements CustomerResourcesService{

    @Autowired
    SysUserMapper sysUserMapper;
    @Override
    public Page<CustomerResources> getCustomerResources(Page<CustomerResources> page, String customerResourcesName, Integer customerResourcesId, String customerResourcesContactPhone, String customerResourcesCustomerSegmentation) {
        QueryWrapper<CustomerResources> query = new QueryWrapper<>();
        if(customerResourcesName!=null&&customerResourcesName.length()>0){
            query.lambda().like(CustomerResources::getCustomerResourcesName,customerResourcesName);
        }
        if(customerResourcesId!=null){
            query.lambda().like(CustomerResources::getCustomerResourcesId,customerResourcesId);
        }
        if(customerResourcesContactPhone!=null&&customerResourcesContactPhone.length()>0){
            query.lambda().like(CustomerResources::getCustomerResourcesContactPhone,customerResourcesContactPhone);
        }
        if(customerResourcesCustomerSegmentation!=null
                &&!customerResourcesCustomerSegmentation.equals("全部")
                &&customerResourcesCustomerSegmentation.length()>0){
            query.lambda().like(CustomerResources::getCustomerResourcesCustomerSegmentation,customerResourcesCustomerSegmentation);
        }
        query.lambda().orderBy(true,false,CustomerResources::getCustomerResourcesId);
        return baseMapper.selectPage(page,query);
    }
}
